package o;

import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.SpinnerInfo;
import com.huawei.appgallery.foundation.ui.framework.titleframe.bean.SpinnerItem;
import com.huawei.appmarket.framework.widget.spinner.SpinnerAdapter;
import com.huawei.appmarket.framework.widget.spinner.TitleSpinner;
import com.huawei.appmarket.support.widget.title.spinner.bean.SpinnerTitleBean;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

public class ewi implements dkt {
    private String ʼ = "";
    private djb ˊ;
    private TitleSpinner ˋ;
    private ArrayAdapter<String> ˎ;
    private Activity ˏ;
    private SpinnerTitleBean ॱ;
    private boolean ॱॱ = true;

    public ewi(Activity activity, TitleSpinner titleSpinner, SpinnerTitleBean spinnerTitleBean) {
        this.ˏ = activity;
        this.ˋ = titleSpinner;
        this.ॱ = spinnerTitleBean;
    }

    public boolean ˎ() {
        if (ˋ(this.ॱ.ˎ())) {
            Logger.e("SpinnerCtrl", "createSpinner: the spinnerR info is null or empty!");
            return false;
        }
        this.ʼ = this.ॱ.ˎ().ˊ();
        final List<SpinnerItem> ॱ = this.ॱ.ˎ().ॱ();
        List arrayList = new ArrayList();
        for (SpinnerItem ॱ2 : ॱ) {
            arrayList.add(ॱ2.ॱ());
        }
        this.ˎ = new SpinnerAdapter(this.ˏ, arrayList);
        this.ˋ.setAdapter(this.ˎ);
        this.ˋ.setOnItemSelectedListener(new OnItemSelectedListener(this) {
            final /* synthetic */ ewi ˊ;

            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
                if (this.ˊ.ˊ == null) {
                    Logger.e("SpinnerCtrl", "iTitleDataChangedListener is null, illegal");
                } else if (this.ˊ.ॱॱ) {
                    Logger.ˎ("SpinnerCtrl", "spinner initialization click");
                } else {
                    SpinnerItem spinnerItem = (SpinnerItem) ॱ.get(i);
                    this.ˊ.ˏ(i, spinnerItem);
                    this.ˊ.ˊ.ˊ(spinnerItem);
                }
            }

            public void onNothingSelected(AdapterView<?> adapterView) {
            }
        });
        this.ˋ.setExtendClick(this);
        return true;
    }

    public void ॱ() {
        this.ॱॱ = false;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("name", this.ʼ);
        if (ˋ(this.ॱ.ˎ())) {
            Logger.e("SpinnerCtrl", "extendsBI: the spinner info is null or empty!");
            return;
        }
        linkedHashMap.put("para", ((SpinnerItem) this.ॱ.ˎ().ॱ().get(0)).ˊ());
        linkedHashMap.put("service_type", Integer.valueOf(dgm.ˎ(this.ˏ)).toString());
        Logger.ˏ("SpinnerCtrl", "spinner extends click BI :" + linkedHashMap.size());
        dgh.ˋ("spinner_click", linkedHashMap);
    }

    private void ˏ(int i, SpinnerItem spinnerItem) {
        if (spinnerItem == null || spinnerItem.ॱ() == null || spinnerItem.ˊ() == null) {
            Logger.e("SpinnerCtrl", "ItemBI: spinnerItem is null or empty");
            return;
        }
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        linkedHashMap.put("itemname", spinnerItem.ॱ());
        linkedHashMap.put("itemindex", Integer.valueOf(i).toString());
        linkedHashMap.put("name", this.ʼ);
        linkedHashMap.put("para", spinnerItem.ˊ());
        linkedHashMap.put("service_type", Integer.valueOf(dgm.ˎ(this.ˏ)).toString());
        Logger.ˏ("SpinnerCtrl", "spinner item click BI :" + linkedHashMap.size());
        dgh.ˋ("spinner_item_click", linkedHashMap);
    }

    public void ॱ(SpinnerTitleBean spinnerTitleBean) {
        if (this.ˎ != null) {
            if (ˋ(spinnerTitleBean.ˎ())) {
                Logger.e("SpinnerCtrl", "refreshAdapter: the spinner info is null or empty!");
                return;
            }
            this.ॱ = spinnerTitleBean;
            this.ʼ = spinnerTitleBean.ˎ().ˊ();
            List<SpinnerItem> ॱ = spinnerTitleBean.ˎ().ॱ();
            this.ˎ.clear();
            for (SpinnerItem ॱ2 : ॱ) {
                this.ˎ.add(ॱ2.ॱ());
            }
            this.ˎ.notifyDataSetChanged();
        }
    }

    private boolean ˋ(SpinnerInfo spinnerInfo) {
        return spinnerInfo == null || CollectCheck.isEmpty(spinnerInfo.ॱ());
    }

    public void ॱ(djb o_djb) {
        this.ˊ = o_djb;
    }
}
